#pragma once
#include <iostream>
#include <thread>
#include "CSession.h"
#include "json/json.h"
#include "json/value.h"
#include "json/reader.h"

class CSession;
class LogicNode;
typedef std::function<void(std::shared_ptr<CSession>, const short&, const std::string& data)> FunCallBack;
class LogicSys
{
public:
	~LogicSys();
	LogicSys(const LogicSys&) = delete;
	LogicSys& operator=(const LogicSys&) = delete;
	void PostMsgToQue(std::shared_ptr<LogicNode>);
	static LogicSys& getInst();
private:
	LogicSys();
	void DealMsg();
	void RegisterCallBack();
	void HelloWorldCallBack(std::shared_ptr<CSession>, const short&, const std::string& data);

	std::thread _work_thread;
	std::queue<std::shared_ptr<LogicNode>> _msg_que;
	std::mutex _mtx;
	std::condition_variable _consume;
	bool _b_stop;
	std::map<short, FunCallBack> _fun_callbacks;
};

